package com.youle.robots.gateway.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by IntelliJ IDEA.
 * User: kedong
 * Date: 18-3-20
 * Time: 上午10:16
 * To change this template use File | Settings | File and Code Templates ->Includes->File Header.
 */
@Configuration
public class WebMvcConfigurer extends WebMvcConfigurerAdapter {

    //授权拦截器
    private final AuthorizeInterceptor authorizeInterceptor;
    //签名拦截器
    private final SignInterceptor signInterceptor;

    @Autowired
    public WebMvcConfigurer(AuthorizeInterceptor authorizeInterceptor, SignInterceptor signInterceptor) {
        this.authorizeInterceptor = authorizeInterceptor;
        this.signInterceptor = signInterceptor;
    }


    //增加拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authorizeInterceptor).addPathPatterns("/api/**");
        registry.addInterceptor(signInterceptor).addPathPatterns("/api/**");

    }

}
